﻿using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using WMSmanagement.IBaseService.OuStorage;

namespace WMSmanagement.Web.Controllers
{
    public class OustorageController : Controller
    {
        private readonly IOuStorageService _ouStorageService;

        public OustorageController(IOuStorageService ouStorageService)
        {
            _ouStorageService = ouStorageService;
        }
        public IActionResult Index()
        {
            return View();
        }
        public IActionResult Add()
        {
            return View();
        }
        public IActionResult OpenProduct()
        {
            return View();
        }
        public async Task<IActionResult> GetOuStorages(string StockOutCode, string StockOutType, int pageIndex, int pageSize)
        {
            var result = await _ouStorageService.GetOuStorages(StockOutCode, StockOutType, pageIndex, pageSize);
            return Json(new { data = result.Data, count = result.TotalCount, code = "0", message = "success" });
        }
        public async Task<IActionResult> GetProducts(int id)
        {
            var result = await _ouStorageService.GetProducts(id);
            return Json(new { data = result, code = "0", message = "success" });

        }
        public async Task<IActionResult> DeleteOuStorage(string StockOutCode)
        {
            var result = await _ouStorageService.DeleteOuStorage(StockOutCode);
            return Json(new { data = result, code = "0", message = result == true ? "success" : "failed" });
        }


    }
}
